/**
 * @Description: 系统设置相关API - 支持读取与更新（单例资源 settings: id=1）
 * @Author: lujq
 * @Date: 2025-08-25
 * @LastEditors: lujq
 * @LastEditTime: 2025-08-25 14:15:00
 */

import { http } from './index'
import type { ApiResponse, SystemSettings } from '@/types'

/**
 * 获取系统设置（包含信用评估与提醒配置）
 * @returns 系统设置对象
 */
export const getSystemSettings = (): Promise<ApiResponse<SystemSettings>> => {
  return http.get('/settings/1')
}

/**
 * 更新系统设置
 * @param data 系统设置对象
 * @returns 更新后的系统设置
 */
export const updateSystemSettings = (
  data: Partial<SystemSettings>,
): Promise<ApiResponse<SystemSettings>> => {
  return http.put('/settings/1', {
    ...data,
    updateTime: new Date().toISOString(),
  })
}